{% from 'bootstrap5/form.html' import render_form %}
{% extends 'base.html' %}
    
{% block page_content %}
<div class="page-header"> 
    <h1>{{ user.username }}</h1> 
    {% if user.name or user.location %} 
    <p> 
        {% if user.name %}{{ user.name }}{% endif %} 
        {% if user.location %} 
            From <a href="http://maps.google.com/?q={{ user.location }}"> 
                {{ user.location }} 
            </a> 
        {% endif %} 
    </p> 
    {% endif %}
    {% if user == current_user %} 
        <a class="btn btn-default" href="{{ url_for('.edit_profile') }}"> 
            Edit Profile 
        </a>
        <a href="{{ url_for('.edit_profile') }}" class="btn btn-primary btn-lg active" role="button" aria-pressed="true">Edit Profile </a>
    {% endif %}
    {% if current_user.is_administrator() %}
        <a href="{{ url_for('.edit_profile_admin', id=user.id) }}" class="btn btn-danger btn-lg active" role="button" aria-pressed="true">Edit Profile[管理员] </a>
    {% endif %} 
    {% if current_user.is_administrator() %} 
    <p><a href="mailto:{{ user.email }}">{{ user.email }}</a></p> 
    {% endif %} 
    {% if user.about_me %}<p>{{ user.about_me }}</p>{% endif %} 
    <p> 
        Member since {{ moment(user.member_since).format('L') }}. 
        Last seen {{ moment(user.last_seen).fromNow() }}. 
    </p>

    <p>
        {% if current_user.can(Permission.FOLLOW) and user != current_user %} 
            {% if not current_user.is_following(user) %} 
                <a href="{{ url_for('.follow', username=user.username) }}" 
                class="btn btn-danger" href="{{ url_for('.follow', username=user.username) }}" role="button">关注</a>
            {% else %} 
                <!-- <a href="{{ url_for('.unfollow', username=user.username) }}" 
                class="btn btn-default">取消关注</a> -->
                <a  class="btn btn-secondary" data-mdb-toggle="tooltip" data-mdb-placement="top" title="取消关注" role="button" href="{{ url_for('.unfollow', username=user.username) }}">
                    已关注
                </a>
            {% endif %} 
        {% endif %} 
        <a href="{{ url_for('.followers', username=user.username) }}"> 
            粉丝: <span class="badge">{{ user.followers.count() }}</span> 
        </a> 
        <!-- <a href="{{ url_for('.followed_by', username=user.username) }}"> 
            关注: <span class="badge">{{ user.followed.count() }}</span> 
        </a>  -->
        <a role="button" class="btn btn-warning btn-rounded position-relative" href="{{ url_for('.followers', username=user.username) }}">
            粉丝数
            <span class="position-absolute top-0 start-100 translate-middle badge rounded-pill badge-danger">
                {{ user.followers.count() }}
              <span class="visually-hidden">unread messages</span>
            </span>
        </a>
        
        <a role="button" class="btn btn-info btn-rounded position-relative" href="{{ url_for('.followed_by', username=user.username) }}">
            关注数
            <span class="position-absolute top-0 start-100 translate-middle badge rounded-pill badge-danger">
                {{ user.followed.count() }}
              <span class="visually-hidden">unread messages</span>
            </span>
        </a>
        {% if current_user.is_authenticated and user != current_user and user.is_following(current_user) %} 
            | <span class="label label-default">Follows you</span> 
        {% endif %}
    </p>

    <div>
        {% if current_user.can(Permission.WRITE) %} 
        {{ render_form(form) }} 
        {% endif %} 
    </div>

    <h3>{{ user.username }} 发表的文章</h3>
    {% include '_posts.html' %}
</div>
    {% block scripts %}
        {{ super() }}
        {{ pagedown.include_pagedown() }}
    {% endblock %}
{% endblock %}